<?php

$redis = new Redis();

$redis->connect('127.0.0.1', 6379);

$redis->auth('redis');

// $redis->set('string', "hello kyo");

// $redis->publish('kyoChat', $argv[1]);

$redis->subscribe(array('kyoChat'), 'sub');

function sub($obj, $chan, $mes)
{
    echo $mes, PHP_EOL;
    $obj->unsubscribe(array('kyoChat'));
    echo 'rPush: ', $obj->rPush('Chat', $mes), PHP_EOL;
    echo $obj->getLastError(), PHP_EOL;
    $obj->subscribe(array('kyoChat'), 'sub');
    echo $obj->getLastError(), PHP_EOL;
}

